package easy;

public class Solution_1175 {

    private int[] arr = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
        83, 89, 97};

    public int numPrimeArrangements(int n) {
        int mod = 1000000000 + 7;
        int count = 0;
        while (count < arr.length && arr[count] <= n) {
            count++;
        }
        int a = n - count;
        long sum = 1;
        while (count > 0) {
            sum *= count--;
            sum %= mod;
        }

        while (a > 0) {
            sum *= a--;
            sum %= mod;
        }
        return (int) sum;
    }

    public static void main(String[] args) {
        Solution_1175 model = new Solution_1175();
        System.out.println(model.numPrimeArrangements(5));
        System.out.println(model.numPrimeArrangements(2));
        System.out.println(model.numPrimeArrangements(1));
        System.out.println(model.numPrimeArrangements(100));
    }
}
